
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('comCrime produces correct results BIC', {
	set.seed(2019)
    comCrime <- get_comCrime()
    vy <- comCrime$vy
    mX <- comCrime$mX
    tic('comCrime produces correct results BIC')
    result <- sampler(100000, vy, mX, prior='BIC', modelprior='uniform', cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.94740000000000002,0.26622000000000001,0.08648000000000000,
0.43586999999999998,0.09908000000000000,0.45071000000000000,
0.04505000000000000,0.07826000000000000,0.04751000000000000,
0.20030000000000001,0.09268000000000000,0.03688000000000000,
0.11712000000000000,0.14110000000000000,0.02372000000000000,
0.03100000000000000,0.08356000000000000,0.04962000000000000,
0.04672000000000000,0.05529000000000000,0.06586000000000000,
0.07400000000000000,0.06235000000000000,0.04791000000000000,
0.03643000000000000,0.02986000000000000,0.07804999999999999,
0.04897000000000000,0.07392000000000000,0.03489000000000000,
0.07693000000000000,0.03548000000000000,0.04866000000000000,
0.02920000000000000,0.04345000000000000,0.02995000000000000,
0.03347000000000000,0.04446000000000000,0.03263000000000000,
0.80427000000000004,0.18221000000000001,0.05037000000000000,
0.21812000000000001,0.77812999999999999,0.04353000000000000,
0.12110000000000000,0.02568000000000000,0.02440000000000000,
0.92418000000000000,0.98036000000000001,0.97057000000000004,
0.04015000000000000,0.05150000000000000,0.15984000000000001,
0.68164999999999998,0.03199000000000000,0.03791000000000000,
0.03491000000000000,0.03524000000000000,0.37684000000000001,
0.05378000000000000,0.08116000000000000,0.05427000000000000,
0.06267000000000000,0.04224000000000000,0.09243000000000000,
0.07270000000000000,0.05966000000000000,0.03249000000000000,
0.02321000000000000,0.90103999999999995,0.06898000000000000,
0.04904000000000000,0.02438000000000000,0.09001000000000001,
0.03362000000000000,0.02942000000000000,0.13260000000000000,
0.37035000000000001,0.23374000000000000,0.24353000000000000,
0.02644000000000000,0.02986000000000000,0.03506000000000000,
0.03605000000000000,0.02414000000000000,0.24012000000000000,
0.02817000000000000,0.21396999999999999,0.38860000000000000,
0.04076000000000000,0.02999000000000000,0.33513999999999999,
0.04466000000000000,0.03532000000000000,0.02461000000000000,
0.02493000000000000,0.02511000000000000,0.70140000000000002
  )
, tolerance = 1e-5)
})